package com.goldcn.ftp.util;

import org.apache.commons.net.ftp.FTPClient;
import java.io.IOException;

/**
 * @Author Li manNa
 * mail: lmn_022@163.com
 * Date: 2017/10/16
 * Time: 10:44
 * To change this template use File | Settings | File Templates.
 */
public class FtpUtil {

   public FTPClient getFtpClient(FTPClient ftpClient, String ftpUrl, String userName, int port,
                                 String password, String directory){
      try {
          ftpClient = new FTPClient();
          ftpClient.connect(ftpUrl,port);
          ftpClient.login(userName, password);
          ftpClient.enterLocalPassiveMode();
          ftpClient.changeWorkingDirectory(directory);
      } catch (IOException e) {
          throw new IOException(e);
      } finally {
          return ftpClient;
      }
   }
}
